﻿<phone:PhoneApplicationPage
    x:Class="Coding4Fun.Lockscreen.Mobile.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="CategoryItemTemplate">
            <StackPanel Orientation="Horizontal" Margin="0,0,0,5" Height="60">
                <Image Source="/Images/folder.png" Margin="0,0,5,0"></Image>
                <TextBlock Foreground="White" Style="{StaticResource PhoneTextTitle2Style}" VerticalAlignment="Center" Text="{Binding Name}"></TextBlock>
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="CustomCategoryItemTemplate">
            <StackPanel Orientation="Horizontal" Margin="0,0,0,5" Height="60">
                <Image Source="/Images/folder.png" Margin="0,0,5,0"></Image>
                <TextBlock Foreground="White" Style="{StaticResource PhoneTextTitle2Style}" VerticalAlignment="Center" Text="{Binding Name}"></TextBlock>

                <toolkit:ContextMenuService.ContextMenu>
                    <toolkit:ContextMenu>
                        <toolkit:MenuItem Tag="{Binding}" Header="delete" x:Name="btnDeleteSet" Click="btnDeleteSet_Click_1"></toolkit:MenuItem>
                    </toolkit:ContextMenu>
                </toolkit:ContextMenuService.ContextMenu>
            </StackPanel>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>
    
    <Grid>
        <phone:Pivot Foreground="White" x:Name="mainPivot" Background="#1266a7">
            <phone:Pivot.TitleTemplate>
                <DataTemplate>
                    <Image Source="/Images/dlock.png" Margin="0,0,24,0"></Image>
                </DataTemplate>
            </phone:Pivot.TitleTemplate>
            <phone:PivotItem Header="web sets">
                <Grid x:Name="LayoutRoot" Background="Transparent">
                    <ListBox 
                        x:Name="lstWebCategories"
                        SelectionMode="Single"
                        SelectionChanged="ListBox_SelectionChanged_1"
                        ItemsSource="{Binding Path=Instance.Categories,
                        Source={StaticResource CentralBindingPoint}}"
                        ItemTemplate="{StaticResource CategoryItemTemplate}">
                    </ListBox>
                </Grid>
            </phone:PivotItem>

            <phone:PivotItem Header="custom sets">
                <ListBox 
                        SelectionMode="Single" x:Name="lstCustomSets"
                        SelectionChanged="lstCustomSets_SelectionChanged_1"
                        ItemsSource="{Binding Path=Instance.CustomCategories,
                        Source={StaticResource CentralBindingPoint}}"
                        ItemTemplate="{StaticResource CustomCategoryItemTemplate}">
                </ListBox>
            </phone:PivotItem>
        </phone:Pivot>

        <Grid x:Name="grdLoading" Visibility="Collapsed">
            <Grid.Background>
                <SolidColorBrush Color="Black" Opacity=".4"></SolidColorBrush>
            </Grid.Background>

            <TextBlock Foreground="White" Text="Loading..." HorizontalAlignment="Center"
                       VerticalAlignment="Center"></TextBlock>
        </Grid>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Default" Opacity="1.0" >
            <shell:ApplicationBarIconButton IconUri="/Images/add.png" Text="add custom" Click="btnAddCustomCategory_Click"/>
            <shell:ApplicationBarIconButton x:Name="btnRefreshSetList" IconUri="/Images/appbar.refresh.png" Text="refresh sets" Click="btnRefreshSetList_Click_1"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>